<link rel="stylesheet" type="text/css" href="css/product.css" />
<p class="group-line">
    <span class="group-title">Top sản phẩm mới</span>
</p>
<?php
	$query = "select id, id_parent_cat, id_sub_cat, code, name, price, image from product order by date_upload desc limit 0, 6";
	$result = $exec_mysql->execute($query, 0);
	$i = 0;
	echo '<table width="725px" align="center">';
	while($row = mysql_fetch_array($result))
	{
		if(@$pcat_name == '')
		{
			$pcat = $row['id_parent_cat'];
			$pcat_name = $exec_mysql->execute("select name from category where id = $pcat", 1);
		}
		
		if(@$scat_name == '')
		{
			$scat = $row['id_sub_cat'];
			$scat_name = $exec_mysql->execute("select name from sub_category where id = $scat", 1);
		}
		
		if($i == 0)
			echo '<tr>';
		echo '<td align="center">';
		echo '<a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$global->remove_sign($scat_name).'/'.$global->remove_sign($row['name']).'/'.$pcat.'/'.$scat.'/'.$row['id'].'.html"><img src="'.$row['image'].'" title="'.$row['name'].'" class="item-pic" /></a>';
		echo '<p class="item-name"><a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$global->remove_sign($scat_name).'/'.$global->remove_sign($row['name']).'/'.$pcat.'/'.$scat.'/'.$row['id'].'.html">'.$row['name'].'</a></p>';
		echo '<p class="item-code">'.number_format($row['price'], 0, ',', '.').' VNĐ</p>';
		echo '</td>';
		
		$i++;
		if($i == 3)
		{
			echo '</tr>';
			$i = 0;
		}
	}
	if($i != 0)
		echo '</tr>';
	echo '</table>';	
?>
<p class="group-line">
    <span class="group-title">Top sản phẩm HOT</span>
</p>
<?php
	$query = "select id, id_parent_cat, id_sub_cat, code, name, price, image from product order by view desc limit 0, 6";
	$result = $exec_mysql->execute($query, 0);
	$i = 0;
	echo '<table width="725px" align="center">';
	while($row = mysql_fetch_array($result))
	{
		if(@$pcat_name == '')
		{
			$pcat = $row['id_parent_cat'];
			$pcat_name = $exec_mysql->execute("select name from category where id = $pcat", 1);
		}
		
		if(@$scat_name == '')
		{
			$scat = $row['id_sub_cat'];
			$scat_name = $exec_mysql->execute("select name from sub_category where id = $scat", 1);
		}
		
		if($i == 0)
			echo '<tr >';
		echo '<td align="center">';
		echo '<a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$global->remove_sign($scat_name).'/'.$global->remove_sign($row['name']).'/'.$pcat.'/'.$scat.'/'.$row['id'].'.html"><img src="'.$row['image'].'" title="'.$row['name'].'" class="item-pic" /></a>';
		echo '<p class="item-name"><a href="san-pham/'.$global->remove_sign($pcat_name).'/'.$global->remove_sign($scat_name).'/'.$global->remove_sign($row['name']).'/'.$pcat.'/'.$scat.'/'.$row['id'].'.html">'.$row['name'].'</a></p>';
		echo '<p class="item-code">'.number_format($row['price'], 0, ',', '.').' VNĐ</p>';
		echo '</td>';
		
		$i++;
		if($i == 3)
		{
			echo '</tr>';
			$i == 0;
		}
	}
	if($i != 0)
		echo '</tr>';
	echo '</table>';
?>